<extend name="Public/list"/>
<block name="menu">
	<ul>
		<li class="on"><span class="search">菜单管理</span></li>
		<li><a href="javascript:lay('{:U('add')}','添加菜单',400,30);" class="add">添加菜单</a></li>
	</ul>
</block>
<block name="search">
	<div class="search_box">
		<form id="searchform">
		菜单名称：<input type="text" name="menu_name" id="menu_name_s" class="text" size="25">
		&nbsp;&nbsp;&nbsp;&nbsp;
		<button class="btn btn_search">搜索</button>
		</form>
	</div>
</block>
<block name="script">
<script id="js">
var url = "{:U('index')}";
$(document).ready(function () {
	jQuery("#dataTable").jqGrid({
		url: url,
		datatype: "json",
		mtype: 'GET',
		colNames:['ID','菜单名称','功能节点','图标','排序','菜单位置','操作'],
		colModel:[
				{name:'id',index:'mid', width:30,align:"center"},
				{name:'menu_name',index:'menu_name', width:100,align:"left"},
				{name:'url',index:'url', width:100,align:"left"}, 
				{name:'ico',index:'ico', width:100,align:"center"},
				{name:'sort_order',index:'sort_order', width:100,align:"center"},
				{name:'position',index:'position', width:100,align:"center"},
				{name:'op',index:'mid',width:100,align:"center"}
				],
		autowidth: true,
		rowNum:50, 
		rowList:[50,100,150], 
		pager: '#pager', 
		sortname: 'pid asc,sort_order', 
		viewrecords: true, 
		sortorder: "asc",
		height:"100%",
		multiselect: true
	});
	jQuery("#searchform").submit( function(){
		loadData();
		return false;
	});
	jQuery("#dataTable")
	.navGrid('#pager',{edit:false,add:false,del:false,search:false})
	.navButtonAdd('#pager',{
		caption:"", 
		buttonicon:"ui-icon-trash", 
		onClickButton: function(){
			var sel,url
			sel = jQuery('#dataTable').jqGrid('getGridParam','selarrrow');
			if(sel=='')
			{
				myAlert('请选择要删除的数据!');
			}
			else
			{
				url = "{:U('remove','id=')}"+sel;
				del('确定要删除所选的记录吗?',url,loadData);
			}
		}, 
		position:"last"
	});
})
function loadData()
{
	var menu_name = jQuery("#menu_name_s").val();
	var search = url+'&menu_name='+menu_name;
	jQuery("#dataTable").jqGrid('setGridParam',{url:search}).trigger("reloadGrid");
}
</script>
</block>
<block name="list">
<div>
	<table id="dataTable" width="100%"></table>
	<div id="pager"></div>
</div>
</block>